// 导入api
import { homeCategoryHead } from '@/api/category'
const state = {
  // 分类数据
  list: [
    { name: '居家', id: 1 },
    { name: '美食', id: 2 },
    { name: '服饰', id: 3 },
    { name: '母婴', id: 4 },
    { name: '个护', id: 5 },
    { name: '严选', id: 6 },
    { name: '数码', id: 7 },
    { name: '运动', id: 8 },
    { name: '杂项', id: 9 }
  ]
}
const mutations = {
  setList (state, newList) {
    state.list = newList
  }
}
const actions = {
  // 分类数据
  async getList ({ commit }) {
    const res = await homeCategoryHead()
    commit('setList', res.result)
    console.log('列表', res)
  }
}
const getters = {}
export default {
  namespaced: true,
  state,
  mutations,
  getters,
  actions
}
